﻿<p>1、设置系统环境变量：<code>MAVEN_HOME</code></p>
<img class="img-responsive" src="http://images.cnitblog.com/blog/67777/201411/031514178926794.png" />
<img class="img-responsive" src="http://images.cnitblog.com/blog/67777/201411/031514199861721.png" />

<p>2、设置环境变量<code>Path</code>，将<code>%MAVEN_HOME%\bin</code>加入<code>Path</code>中，一定要注意要用分号；与其他值隔开，如下图所示：</p>
<img class="img-responsive" src="http://images.cnitblog.com/blog/67777/201411/031514233143105.png" />
<div class="bs-callout bs-callout-warning">
    <h4>说明</h4>
    <p><code>%MAVEN_HOME%\bin</code>代表的就是<code>E:\apache-maven-3.2.3\bin</code>目录</p>
</div>

<p>3、验证<code>Maven</code>安装是否成功</p>
<ol>
    <li>打开<code>cmd</code>窗口</li>
    <li>
        输入<code>mvn –v</code>命令 查看<code>Maven</code>的相关信息，如下图所示：
        <img class="img-responsive" src="" />
        <p>能够出现这样的信息就说明<code>Maven</code>的安装已经成功了。</p>
    </li>
</ol>

<p>4、设置<code>MAVEN_OPTS</code>环境变量(可选配置)</p>
<p>
    由于<code>Maven</code>命令实际上是执行了<code>Java</code>命令，所以可以通过<code>JAVA</code>命令
    参数的方式来设置<code>Maven</code>运行参数。<code>MAVEN_OPTS</code>环境变量正是用于此用途
</p>
<p><code>-Xms128m</code> <code>-Xmx512m</code>，分别设置<code>JVM</code>的最小和最大内存，如下图所示：</p>
<img class="img-responsive" src="http://images.cnitblog.com/blog/67777/201411/031514272208444.png" />
<div class="bs-callout bs-callout-warning">
    <h4>官方安装教程</h4>
    <p>地址：<a href="http://maven.apache.org/download.cgi#Installation" target="_blank">http://maven.apache.org/download.cgi#Installation</a></p>
    <ol>
        <li>Unzip the distribution archive, i.e. apache-maven-3.2.3-bin.zip to the directory you wish to install Maven 3.2.3. These instructions assume you chose C:\Program Files\Apache Software Foundation. The subdirectory apache-maven-3.2.3 will be created from the archive.</li>
        <li>Add the M2_HOME environment variable by opening up the system properties (WinKey + Pause), selecting the "Advanced" tab, and the "Environment Variables" button, then adding the M2_HOME variable in the user variables with the value C:\Program Files\Apache Software Foundation\apache-maven-3.2.3. Be sure to omit any quotation marks around the path even if it contains spaces. Note: For Maven 2.0.9, also be sure that the M2_HOME doesn't have a '\' as last character.</li>
        <li>In the same dialog, add the M2 environment variable in the user variables with the value %M2_HOME%\bin.</li>
        <li>Optional: In the same dialog, add the MAVEN_OPTS environment variable in the user variables to specify JVM properties, e.g. the value -Xms256m -Xmx512m. This environment variable can be used to supply extra options to Maven.</li>
        <li>In the same dialog, update/create the Path environment variable in the user variables and prepend the value %M2% to add Maven available in the command line.</li>
        <li>In the same dialog, make sure that JAVA_HOME exists in your user variables or in the system variables and it is set to the location of your JDK, e.g. C:\Program Files\Java\jdk1.7.0_51and that %JAVA_HOME%\bin is in your Path environment variable.</li>
        <li>Open a new command prompt (Winkey + R then type cmd) and run mvn --version to verify that it is correctly installed.</li>
    </ol>
</div>
